from selenium import webdriver
from selenium.webdriver.chrome.service import Service
# 1导入包 2初始化一个浏览器对象3打开指定url界面
#2.1需要指定浏览器位置,2.2如果浏览器驱动包没有放在python目录下,需要指定浏览器驱动位置
# driver=webdiver.Chrome() 默认

# 2.1
chrome_location=r'D:\Soft\chrome-win\chrome.exe'#浏览器路径
options=webdriver.ChromeOptions()#初始化对象
options.binary_location=chrome_location
# 2.2
driver_location=r'D:\Users\admin\AppData\Local\Programs\Python\Python38\chromedriver.exe'
service=Service(driver_location)
driver=webdriver.Chrome(options=options,service=service)

driver.get(url='https://www.baidu.com/')
